package com.jy.adscm.operation.mscyb.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.jy.adscm.bean.system.JyUser;
import com.jy.adscm.operation.mscyb.bean.JqdbMachinepackingdetail;
import com.jy.adscm.operation.mscyb.mapper.mysql.JqdbMachinepackingdetailMapper;
import com.jy.adscm.operation.mscyb.service.JqdbMachinepackingdetailService;
import com.jy.adscm.system.mapper.mysql.JyUserMapper;
import com.jy.adscm.utils.AdscmBaseUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zyl
 * @since 2018-12-06
 */
@Service
public class JqdbMachinepackingdetailServiceImpl extends ServiceImpl<JqdbMachinepackingdetailMapper, JqdbMachinepackingdetail> implements JqdbMachinepackingdetailService {
   @Autowired
    JyUserMapper jyUserMapper;
    @Override
    public List<JqdbMachinepackingdetail> selectByTid(String tid) {
        Wrapper<JqdbMachinepackingdetail> wrapper=new EntityWrapper<>();
        wrapper.eq("TID",tid);
        List<JqdbMachinepackingdetail> jqdbMachinepackingdetails = super.selectList(wrapper);
        for (JqdbMachinepackingdetail jqdbMachinepackingdetail : jqdbMachinepackingdetails) {
            if(AdscmBaseUtils.getInstance().isNotEmpty(jqdbMachinepackingdetail.getUser(),null)){
                JyUser jyUser = jyUserMapper.selectById(jqdbMachinepackingdetail.getUser());
                jqdbMachinepackingdetail.setUserName(jyUser.getName());
            }
        }
        return jqdbMachinepackingdetails;
    }
}
